﻿//===========================[ 8 / 7 / 2011 LVI ]=============================
//				Copyright c Vitaly Lyaschenko <SkyChameleon@gmail.com>
//								Source file
// Purpose: 
//=============================================================================
#include "gl3com.h"
//#include <GL/glew.h>
//#include <GL/wglew.h>

#include "cProgramManager.h"
#include "cwLogger.h"

std::map<std::string,cShaderProgram*> cProgramManager::m_ShaderProgram;

cProgramManager::cProgramManager()
{
	cwLogger::writeINFO("< Program Manager > Instance Create.");
}

cProgramManager::~cProgramManager()
{
	clearAllProgram();

	cwLogger::writeINFO("< Program Manager > Instance Destroy.");
}

///////////////////////////////////////////////////////////////////////////
// положить программу в стек
bool cProgramManager::createProgram( const char* VertFile, const char* fragFile, const char* nameProgram )
{
//	cShader _vertShader, _fragShader;
//
//	if ( ! _vertShader.load(VertFile,GL_VERTEX_SHADER) )
//		return false;
//	if ( ! _fragShader.load(fragFile,GL_FRAGMENT_SHADER) )
//		return false;
//
//	m_ShaderProgram[nameProgram] = new cShaderProgram;
//	m_ShaderProgram[nameProgram]->create();
//	m_ShaderProgram[nameProgram]->attach(_vertShader);
//	m_ShaderProgram[nameProgram]->attach(_fragShader);
//	{

	m_ShaderProgram[ nameProgram ] = new cShaderProgram( VertFile, fragFile );
	cwLogger::writeINFO( "Program : " + std::string( nameProgram ) + " create!" );
	return m_ShaderProgram[ nameProgram ]->getStatus();
}
// положить программу в стек
bool cProgramManager::createProgram( cShaderProgram *program, const char* nameProgram )
{
	m_ShaderProgram[ nameProgram ] = program;
	cwLogger::writeINFO( "Program : " + std::string( nameProgram ) + " add!" );
	return m_ShaderProgram[ nameProgram ]->getStatus();
}